<?php
		require_once('../inc/facebook.php');
		
		if(isset($_POST['count']))
			$c=$_POST['count'];
		else
			$c=0;
			
		if(isset($_POST['total']))
			$t=$_POST['total'];
		else
			$t=0;
			
        $facebook = new Facebook(array(
                'appId' => '133491496805876',
                'secret' => '75ca045c26d2ad30854e7cde4ebffa94'
        ));
       
        $fbUser = $facebook->getUser();
        //echo $facebook->getAccessToken();
		
        if(isset($_POST['card_num']))
        {
        require_once '../inc/anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
        $transaction = new AuthorizeNetAIM('5Y34Szq74', '6rjRMTG98b2267GV');
       
        $transaction->amount = $_POST['price'];
        $transaction->card_num = $_POST['card_num'];
        $transaction->exp_date = $_POST['exp_date'];
       
        $response = $transaction->authorizeAndCapture();
        }
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
    <script type = "text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
    <script type = "text/javascript" src="inc/drop.js"></script>
    <link href="inc/styles.css" rel="stylesheet" type="text/css" />
    <link href="inc/dropstyle.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Home Page</title>
    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">

</head>

<body>
	<div id="content">
            <header>
                <? include('inc/header.php'); ?>
            </header>
    
        	<nav>
                        <? include('inc/nav.php'); ?>
            </nav>
            
            <div id="checkout">
                <pre>
                            <?
                                    if (isset($response)) {
                                            print_r($response);
                                    }
                            ?>
                </pre>
               
                <form action="?" method="post">
                    <input type="number" type="hidden" name="price" value="<?= $t ?>" />
                    Price: <?= $t ?> <br />
                    Credit Card Number: <input type="text" name="card_num" /> <br />
                    Experation Date: <input type="text" name="exp_date" /></br />
                    <input type="submit" value="Buy Now" />
                </form>
            </div>
        </div>
        <div id="fb-root"></div>
                <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
</body>
</html>
